import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'JvtdStringLocalized.dart';
import 'JvtdString.dart';
//多语言代理
class JvtdStringLocalizedDelegate extends LocalizationsDelegate<JvtdStringLocalized> {
  JvtdStringLocalizedDelegate();

  @override
  bool isSupported(Locale locale) {
    ///支持中文和英语
    return [JvtdString.ZH, JvtdString.EN].contains(locale.languageCode);
  }

  ///根据locale，创建一个对象用于提供当前locale下的文本显示
  @override
  Future<JvtdStringLocalized> load(Locale locale) {
    return new SynchronousFuture<JvtdStringLocalized>(new JvtdStringLocalized(locale));
  }

  @override
  bool shouldReload(LocalizationsDelegate<JvtdStringLocalized> old) {
    return false;
  }

  ///全局静态的代理
  static JvtdStringLocalizedDelegate delegate = new JvtdStringLocalizedDelegate();
}
